<?php require_once('Connections/FitConnec.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO fit (`Matrix number`, Name, Email, Password, `Phone number`) VALUES (%s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['matrixnumber'], "int"),
                       GetSQLValueString($_POST['name'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['Password'], "text"),
                       GetSQLValueString($_POST['phonenumber'], "int"));

  mysql_select_db($database_FitConnec, $FitConnec);
  $Result1 = mysql_query($insertSQL, $FitConnec) or die(mysql_error());

  $insertGoTo = "Login.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_FitConnec, $FitConnec);
$query_Recordset_Signup = "SELECT * FROM fit";
$Recordset_Signup = mysql_query($query_Recordset_Signup, $FitConnec) or die(mysql_error());
$row_Recordset_Signup = mysql_fetch_assoc($Recordset_Signup);
$totalRows_Recordset_Signup = mysql_num_rows($Recordset_Signup);mysql_select_db($database_FitConnec, $FitConnec);
$query_Recordset_Signup = "SELECT * FROM fit";
$Recordset_Signup = mysql_query($query_Recordset_Signup, $FitConnec) or die(mysql_error());
$row_Recordset_Signup = mysql_fetch_assoc($Recordset_Signup);
$totalRows_Recordset_Signup = mysql_num_rows($Recordset_Signup);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FIT Store</title>
   <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <meta name="viewport" content="width=device-width" />
<style type="text/css">
body {
	background-image: url(purple-galaxy.png);
}
body,td,th {
	color: #0FF;
	font-size: 14px;
}
   </style>
<link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" />
<!-- Mobile1 -->
<link href="mobile1.min.css" rel="stylesheet" type="text/css" media="only screen and (max-width:800px)" />
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script>
</head>

<body>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
  
  
  
<div class="navbar navbar-inverse">
  <div class="navbar-inner">
  <a class="brand divider" href="">FIT Store</a>
  <ul class="nav">
  
    <li class="active"></li>
    <li class="active"><a href="Sign up.php">Sign Up</a></li>
    <li ><a href="Login.php">Login</a></li>
    <li ><a href="admin.php">Admin</a></li>
  </ul>
  </div>
</div>
<p id="a">&nbsp;</p>
<p>Welcome to Our Sign Up Page</p>
<form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
  <p>Matric Number<br />
  <span id="sprytextfield1"><span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></p>
  <table width="1059" border="0">
    <tr>
      <td width="568" height="30">&nbsp;</td>
      <td width="481"><span id="sprytextfield4">
      <input name="matrixnumber" type="text" id="textfield2" value="99999" size="5" maxlength="5" />
      <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
    </tr>
  </table>
  <p><span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid forma</span>
    <label for="phonenumber">Name<br />
    </label>
  </p>
  <table width="1059" border="0">
    <tr>
      <td width="568">&nbsp;</td>
      <td width="481"><span id="sprytextfield8">
        <input name="name" type="text" id="name" size="100" maxlength="100" />
      </span></td>
    </tr>
  </table>
  <p>
    <label for="textfield8">Your Email Address<br />
    </label>
  </p>
  <table width="1059" border="0">
    <tr>
      <td width="568">&nbsp;</td>
      <td width="481"><span id="sprytextfield5">
        <input name="email" type="text" id="textfield" value="abc@hotmail.com" size="100" maxlength="100" />
        <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
    <tr> </tr>
  </table>
  <p><span id="sprytextfield2"><span class="textfieldRequiredMsg">A value is required</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></p>
  <p>
    <label for="textfield5"><span id="sprypassword1">Password<br />
    </span></label>
  </p>
  <table width="1059" border="0">
    <tr>
      <td width="568">&nbsp;</td>
      <td width="481"><span id="sprytextfield6"><span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span><span id="sprypassword2">
        <input type="password" name="Password" id="Password" />
      <span class="passwordRequiredMsg">A value is required.</span></span></td>
</tr>
    <tr> </tr>
  </table>
  <p>
    <label for="name">Phone number<br />
    </label>
  </p>
  <table width="1059" border="0">
    <tr>
      <td width="568">&nbsp;</td>
      <td width="481"><span id="sprytextfield7">
        <input name="phonenumber" type="text" id="textfield3" value="0123456789" size="20" maxlength="20" />
        <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
    <tr> </tr>
    <tr> </tr>
  </table>
  <p>
    <label for="name">      <br />
    </label>
    <span id="sprytextfield3"><span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></p>
  <p>
  <input type="submit" value="Sign up"></p>
  <p>
    <input type="hidden" name="MM_insert" value="form1" />
  </p>
</form>
<p>&nbsp;</p>
<script type="text/javascript">
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "phone_number", {format:"phone_custom"});
var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1");
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "integer");
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "integer");
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "email");
var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1");
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "integer");
var sprypassword2 = new Spry.Widget.ValidationPassword("sprypassword2");
var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7", "phone_number", {format:"phone_custom"});
var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8", "none");
</script>
</body>
</html>
<?php
mysql_free_result($Recordset_Signup);
?>
